﻿using System;
using System.Runtime.Serialization;

namespace Phatent.Model.Pages
{
    [DataContract]
    public class PageModel:MBase
    {
        [DataMember]
        [Model(ConvertType = AttributeType.IgnoreUpdate)]
        public int ID { get; set; }
        [DataMember]
        [Model(ConvertType = AttributeType.IgnoreUpdate)]
        public int CaseID { get; set; }
        [DataMember]
        [Model]
        public string Title { get; set; }
        [DataMember]
        [Model]
        public string Description { get; set; }
        [DataMember]
        [Model]
        public string Thumbnail { get; set; }
        [DataMember]
        [Model]
        public int Pindex { get; set; }
        [DataMember]
        [Model(ConvertType = AttributeType.IgnoreUpdate)]
        public System.DateTime CreatedOn { get; set; }
        [DataMember]
        [Model]
        public bool Visible { get; set; }
        [DataMember]
        [Model(ConvertType = AttributeType.IgnoreUpdate)]
        public string FriendUrl { get; set; }
        [DataMember]
        [Model]
        public string Abbreviation { get; set; }
        [DataMember]
        [Model(ConvertType = AttributeType.IgnoreUpdate)]
        public DateTime? TopTime { get; set; }
        [DataMember]
        [Model]
        public int PageType { get; set; }
        [DataMember]
        [Model]
        public string ETitle { get; set; }
        [DataMember]
        [Model]
        public string EDescription { get; set; }
        [DataMember]
        [Model]
        public string EAbbreviation { get; set; }

        #region Help
        [DataMember]
        public string ETitleSub
        {
            get
            {
                if (!string.IsNullOrEmpty(ETitle))
                {
                    if (ETitle.Length > 48)
                        return ETitle.Substring(0, 48) + "...";
                    else
                        return ETitle;
                }
                else
                    return "";
            }
        }
        #endregion
    }

    public class PageCollection : ModelCollectionBase<PageModel> { }
}
